ot = "([{<"
zk = ")]}>"
print("Введите скобочную последовательность")
s = input()
otsk = 0
zksk = 0
stak = []
for i in s:
    if i in ot:
        otsk += 1
    else:
        zksk += 1
if otsk != zksk:
    print("False")
else:
    for i in s:
        if i in ot:
            stak += [i]
        else:
            if ot.index(stak[-1]) != zk.index(i):
                print("False")
                break
            else:
                del stak[-1]

    else:
        print("True")
